#pragma once

class CFileIO : public IStream
{
    CFileIO(const CFileIO&);
    CFileIO& operator=(const CFileIO&);
    
public:

    CFileIO();
    virtual ~CFileIO();
    
    HRESULT Open(
                const wchar_t* strFileName,
                DWORD dwDesiredAccess,
                DWORD dwShareMode,
                DWORD dwCreationDisposition,
                DWORD dwFlagsAndAttributes);
                
    HRESULT Close();
    
    HRESULT STDMETHODCALLTYPE QueryInterface(const IID&, void**);
    ULONG STDMETHODCALLTYPE AddRef();
    ULONG STDMETHODCALLTYPE Release();

    HRESULT STDMETHODCALLTYPE Read(void*, ULONG, ULONG*);    
    HRESULT STDMETHODCALLTYPE Write(const void*, ULONG cb, ULONG*);
    
    HRESULT STDMETHODCALLTYPE Seek( 
        LARGE_INTEGER,
        DWORD,
        ULARGE_INTEGER*);
    
    HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER);
    
    //HRESULT GetSize(ULARGE_INTEGER&) const;
    
    HRESULT STDMETHODCALLTYPE CopyTo( 
        IStream*,
        ULARGE_INTEGER,
        ULARGE_INTEGER*,
        ULARGE_INTEGER*);
    
    HRESULT STDMETHODCALLTYPE Commit(DWORD);
    
    HRESULT STDMETHODCALLTYPE Revert();
    
    HRESULT STDMETHODCALLTYPE LockRegion( 
        ULARGE_INTEGER,
        ULARGE_INTEGER,
        DWORD);
    
    HRESULT STDMETHODCALLTYPE UnlockRegion( 
        ULARGE_INTEGER,
        ULARGE_INTEGER,
        DWORD);
    
    HRESULT STDMETHODCALLTYPE Stat(STATSTG*, DWORD);
    
    HRESULT STDMETHODCALLTYPE Clone(IStream**);

private:

    HANDLE m_hFile;

};
